package src.io;

import java.io.*;

public class MyDataInputOutputStream {
    public static void main(String[] args)throws IOException {

        File file=new File("demo");
        if(!file.exists()){
            file.mkdir();
        }
        File  file2=new File("demo/text.txt");
        if(!file2.exists()){
            file2.createNewFile();
        }
        DataOutputStream dataOutputStream=new DataOutputStream(new FileOutputStream(file2,true));
        dataOutputStream.writeInt(100);
        dataOutputStream.writeInt(-100);
        dataOutputStream.writeLong(1000l);
        dataOutputStream.writeDouble(1000.5);
        dataOutputStream.writeUTF("你好");
        dataOutputStream.writeChars("中国");
     /*   File  file3=new File("demo/outText.txt");
        if(!file3.exists()){
            file3.createNewFile();
        }*/
        DataInputStream dataInputStream=new DataInputStream(new FileInputStream(file2));
        System.out.println(dataInputStream.readInt());
        System.out.println(dataInputStream.readInt());
        System.out.println(dataInputStream.readLong());
        System.out.println(dataInputStream.readDouble());
        System.out.println(dataInputStream.readUTF());
        System.out.println(dataInputStream.readChar());
        System.out.println(dataInputStream.readChar());
        dataOutputStream.close();
        dataInputStream.close();
    }
}
